﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace POS
{
    /// <summary>
    /// Interaction logic for Meals.xaml
    /// </summary>
    public partial class Meals : Window
    {
        double chickenPrice = 5.00;
        double fishPrice = 6.50;
        double pizzaPrice = 7.00;
        double ricePrice = 4.00;
        double spaghettiPrice = 6.50;
        double steakPrice = 9.00;

        public Meals()
        {
            InitializeComponent();
        }

        private void ButtonBackToMainMenu(object sender, RoutedEventArgs e)
        {
            MainWindow mainMenuWindow = new MainWindow();
            mainMenuWindow.Show();
            this.Close();
        }

        private void GoToOrdered(object sender, RoutedEventArgs e)
        {
            Ordered orderedMenu = new Ordered();
            orderedMenu.Show();
            this.Close();
        }

        private void ButtonChicken(object sender, RoutedEventArgs e)
        {
            if ((this.TextBoxChickenCount.Text != "0") && (this.TextBoxChickenCount.Text != String.Empty))
            {
                for (int i = 0; i < int.Parse(this.TextBoxChickenCount.Text); i++)
                {
                    Table.orderList.Add(new Food("Chicken", chickenPrice, 5, FoodOptions.Size.g250, FoodOptions.Type.Salad));
                }
            }
        }

        private void ButtonFish(object sender, RoutedEventArgs e)
        {
            if ((this.TextBoxFishCount.Text != "0") && (this.TextBoxFishCount.Text != String.Empty))
            {
                for (int i = 0; i < int.Parse(this.TextBoxFishCount.Text); i++)
                {
                    Table.orderList.Add(new Food("Fish", fishPrice, 5, FoodOptions.Size.g250, FoodOptions.Type.Salad));
                }
            }
        }

        private void Pizza(object sender, RoutedEventArgs e)
        {
            if ((this.TextBoxPizzaCount.Text != "0") && (this.TextBoxPizzaCount.Text != String.Empty))
            {
                for (int i = 0; i < int.Parse(this.TextBoxPizzaCount.Text); i++)
                {
                    Table.orderList.Add(new Food("Pizza", pizzaPrice, 5, FoodOptions.Size.g250, FoodOptions.Type.Salad));
                }
            }
        }

        private void ButtonRice(object sender, RoutedEventArgs e)
        {
            if ((this.TextBoxRiceCount.Text != "0") && (this.TextBoxRiceCount.Text != String.Empty))
            {
                for (int i = 0; i < int.Parse(this.TextBoxRiceCount.Text); i++)
                {
                    Table.orderList.Add(new Food("Rice", ricePrice, 5, FoodOptions.Size.g250, FoodOptions.Type.Salad));
                }
            }
        }

        private void ButtonSpaghetti(object sender, RoutedEventArgs e)
        {
            if ((this.TextBoxSpaghettiCount.Text != "0") && (this.TextBoxSpaghettiCount.Text != String.Empty))
            {
                for (int i = 0; i < int.Parse(this.TextBoxSpaghettiCount.Text); i++)
                {
                    Table.orderList.Add(new Food("Spaghetti", spaghettiPrice, 5, FoodOptions.Size.g250, FoodOptions.Type.Salad));
                }
            }
        }

        private void ButtonSteak(object sender, RoutedEventArgs e)
        {
            if ((this.TextBoxSteakCount.Text != "0") && (this.TextBoxSteakCount.Text != String.Empty))
            {
                for (int i = 0; i < int.Parse(this.TextBoxSteakCount.Text); i++)
                {
                    Table.orderList.Add(new Food("Steak", steakPrice, 5, FoodOptions.Size.g250, FoodOptions.Type.Salad));
                }
            }
        }
        

        private void RemoveCountChickenButton_Click(object sender, RoutedEventArgs e)
        {
            if (this.TextBoxChickenCount.Text == String.Empty)
            {
                this.TextBoxChickenCount.Text = "0";
            }

            if (int.Parse(this.TextBoxChickenCount.Text) > 0)
            {
                this.TextBoxChickenCount.Text = (int.Parse(this.TextBoxChickenCount.Text) - 1).ToString();
            }
        }

        private void AddCountChickenButton_Click(object sender, RoutedEventArgs e)
        {
            if (this.TextBoxChickenCount.Text == String.Empty)
            {
                this.TextBoxChickenCount.Text = "0";
            }
            this.TextBoxChickenCount.Text = (int.Parse(this.TextBoxChickenCount.Text) + 1).ToString();
        }

        private void RemoveCountFishButton_Click(object sender, RoutedEventArgs e)
        {
            if (this.TextBoxFishCount.Text == String.Empty)
            {
                this.TextBoxFishCount.Text = "0";
            }

            if (int.Parse(this.TextBoxFishCount.Text) > 0)
            {
                this.TextBoxFishCount.Text = (int.Parse(this.TextBoxFishCount.Text) - 1).ToString();
            }
        }

        private void AddCountFishButton_Click(object sender, RoutedEventArgs e)
        {
            if (this.TextBoxFishCount.Text == String.Empty)
            {
                this.TextBoxFishCount.Text = "0";
            }
            this.TextBoxFishCount.Text = (int.Parse(this.TextBoxFishCount.Text) + 1).ToString();
        }

        private void RemoveCountPizzaButton_Click(object sender, RoutedEventArgs e)
        {
            if (this.TextBoxPizzaCount.Text == String.Empty)
            {
                this.TextBoxPizzaCount.Text = "0";
            }

            if (int.Parse(this.TextBoxPizzaCount.Text) > 0)
            {
                this.TextBoxPizzaCount.Text = (int.Parse(this.TextBoxPizzaCount.Text) - 1).ToString();
            }
        }

        private void AddCountPizzaButton_Click(object sender, RoutedEventArgs e)
        {
            if (this.TextBoxPizzaCount.Text == String.Empty)
            {
                this.TextBoxPizzaCount.Text = "0";
            }
            this.TextBoxPizzaCount.Text = (int.Parse(this.TextBoxPizzaCount.Text) + 1).ToString();
        }

        private void RemoveCountRiceButton_Click(object sender, RoutedEventArgs e)
        {
            if (this.TextBoxRiceCount.Text == String.Empty)
            {
                this.TextBoxRiceCount.Text = "0";
            }

            if (int.Parse(this.TextBoxRiceCount.Text) > 0)
            {
                this.TextBoxRiceCount.Text = (int.Parse(this.TextBoxRiceCount.Text) - 1).ToString();
            }
        }

        private void AddCountRiceButton_Click(object sender, RoutedEventArgs e)
        {
            if (this.TextBoxRiceCount.Text == String.Empty)
            {
                this.TextBoxRiceCount.Text = "0";
            }
            this.TextBoxRiceCount.Text = (int.Parse(this.TextBoxRiceCount.Text) + 1).ToString();
        }

        private void RemoveCountSpaghettiButton_Click(object sender, RoutedEventArgs e)
        {
            if (this.TextBoxSpaghettiCount.Text == String.Empty)
            {
                this.TextBoxSpaghettiCount.Text = "0";
            }

            if (int.Parse(this.TextBoxSpaghettiCount.Text) > 0)
            {
                this.TextBoxSpaghettiCount.Text = (int.Parse(this.TextBoxSpaghettiCount.Text) - 1).ToString();
            }
        }

        private void AddCountSpaghettiButton_Click(object sender, RoutedEventArgs e)
        {
            if (this.TextBoxSpaghettiCount.Text == String.Empty)
            {
                this.TextBoxSpaghettiCount.Text = "0";
            }
            this.TextBoxSpaghettiCount.Text = (int.Parse(this.TextBoxSpaghettiCount.Text) + 1).ToString();
        }

        private void RemoveCountSteakButton_Click(object sender, RoutedEventArgs e)
        {
            if (this.TextBoxSteakCount.Text == String.Empty)
            {
                this.TextBoxSteakCount.Text = "0";
            }

            if (int.Parse(this.TextBoxSteakCount.Text) > 0)
            {
                this.TextBoxSteakCount.Text = (int.Parse(this.TextBoxSteakCount.Text) - 1).ToString();
            }
        }

        private void AddCountSteakButton_Click(object sender, RoutedEventArgs e)
        {
            if (this.TextBoxSteakCount.Text == String.Empty)
            {
                this.TextBoxSteakCount.Text = "0";
            }
            this.TextBoxSteakCount.Text = (int.Parse(this.TextBoxSteakCount.Text) + 1).ToString();
        }
    }
}
